package com.example.vod.controller;

import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.exceptions.ServerException;
import com.aliyuncs.vod.model.v20170321.GetVideoPlayAuthRequest;
import com.aliyuncs.vod.model.v20170321.GetVideoPlayAuthResponse;
import com.example.vod.utils.InitVodClient;

public class TestVodAuth {
	public static void main(String[] args) {
		String accessKeyId = "LTAI4GJPGzBeJ5jNNniq6kAj";
		String accessKeySecret = "P01LGdhFP3ghj7VZ8H1dZnTRPrPoRh";
		System.out.println("获取凭证");

		//初始化
		DefaultAcsClient client = InitVodClient.initVodClient(accessKeyId, accessKeySecret);

		//请求
		GetVideoPlayAuthRequest request = new GetVideoPlayAuthRequest();
		request.setVideoId("6abcf43015a14eabb5f4052097d30a4c");

		//响应
		GetVideoPlayAuthResponse response = null;
		try {
			response = client.getAcsResponse(request);
		} catch (ServerException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (ClientException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		//得到播放凭证
		String playAuth = response.getPlayAuth();
		System.out.println(playAuth);
	}

}
